﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.MT3DMS.DomainLayer
{

    [Serializable]
   public class ChemicalSpecies:ICloneable
    {

        public ChemicalSpecies(string name,int nrows,int ncols,int nlayers)
        {

            this._spName = name;

            this._srcConc = new List<double[,]>();

            this._sp1 = new List<double[,]>();

            this._sp2 = new List<double[,]>();


            this._rc1 = new List<double[,]>();

            this._rc2 = new List<double[,]>();


            for (int i = 0; i < nlayers; i++)
            {
                this._srcConc.Add(new double[nrows, ncols]);
                this._sp1.Add(new double[nrows, ncols]);
                this._sp2.Add(new double[nrows, ncols]);
                this._rc1.Add(new double[nrows, ncols]);
                this._rc2.Add(new double[nrows, ncols]);               
            }

        }
        public ChemicalSpecies()
        {
        }

        string _spName;

        public string SpName
        {
            get { return _spName; }
            set { _spName = value; }
        }




        List<double[,]> _srcConc;

        /// <summary>
        /// ic sorbed phase
        /// </summary>
        public List<double[,]> SrcConc
        {
            get { return _srcConc; }
            set { _srcConc = value; }
        }



        List<double[,]> _sp1;


        /// <summary>
        /// 1st sorption conc
        /// </summary>
        public List<double[,]> Sp1
        {
            get { return _sp1; }
            set { _sp1 = value; }
        }

        List<double[,]> _sp2;

        /// <summary>
        /// 2nd sorption conc
        /// </summary>
        public List<double[,]> Sp2
        {
            get { return _sp2; }
            set { _sp2 = value; }
        }



        List<double[,]> _rc1;

        /// <summary>
        /// Rate const (dissolve)
        /// </summary>
        public List<double[,]> Rc1
        {
            get { return _rc1; }
            set { _rc1 = value; }
        }

        List<double[,]> _rc2;

        /// <summary>
        /// Rate const (solve)
        /// </summary>
        public List<double[,]> Rc2
        {
            get { return _rc2; }
            set { _rc2 = value; }
        }




        public void OnSpeciesReset(List<string> spNames)
        {



        }


        public void OnGridReset(int nrows, int ncols, int nlayers)
        {
            this._srcConc.Clear();
            this._sp1.Clear();
            this._sp2.Clear();
            this._rc1.Clear();
            this._rc2.Clear();
            for (int i = 0; i < nlayers; i++)
            {
                this._srcConc.Add(new double[nrows, ncols]);
                this._sp1.Add(new double[nrows, ncols]);
                this._sp2.Add(new double[nrows, ncols]);
                this._rc1.Add(new double[nrows, ncols]);
                this._rc2.Add(new double[nrows, ncols]);
            }
        }
        public object Clone()
        {
            ChemicalSpecies obj = new ChemicalSpecies();
            obj =(ChemicalSpecies) this.MemberwiseClone();
            obj._rc1 = new List<double[,]>();
            foreach (double [,] item in this ._rc1 )
            {
                obj._rc1.Add((double [,]) item.Clone());
            }
            obj._rc2 = new List<double[,]>();
            foreach (double [,] item in this ._rc2)
            {
                obj._rc2.Add((double[,])item.Clone());
            }
            obj._sp1 = new List<double[,]>();
            foreach (double [,] item in this ._sp1)
            {
                obj._sp1.Add((double[,])item.Clone());
            }
            obj._sp2 = new List<double[,]>();
            foreach (double [,] item in this ._sp2)
            {
                obj._sp2.Add((double[,])item.Clone());
            }
            obj._srcConc = new List<double[,]>();
            foreach (double [,] item in this ._srcConc )
            {
                obj._srcConc.Add((double[,])item.Clone());
            }
            return obj;
        }




    }
}
